CP_GAME_SUB_TYPE_DCT = {
    'metis': {'name': "METIS"},
    'game': {'name': "自营电玩城"}
}


CP_GAME_THIRD_TYPE_DCT = {
    '5500': {'name': "超级牛牛"},
    '5501': {'name': "欢乐炸金花"},
    '5502': {'name': "超级六"},
    '5503': {'name': "龙虎斗"},
    '5504': {'name': "金鲨银鲨"},
    '5600': {'name': "放克猴子"},
    'bull': {'name': "百人牛牛"},
    'lottery': {'name': "大转盘"},
    'fruit': {'name': "水果机"}
}


EVENT_RULES = {
    "aggs": {
        "groups": [
            {
                "group_name": "电玩城种类/游戏",
                "field_id": "cp_game_sub_type",
                "is_keyword": True,
                "field_name": "电玩城种类",
                "sub_fields": [
                    {
                        "field_id": "cp_game_third_type",
                        "is_keyword": True,
                        "field_name": "游戏"
                    },
                ]
            },
            {
                "group_name": "渠道",
                "field_id": "_chn",
                "is_keyword": True,
                "field_name": "渠道"
            }

        ],
        "values": [
            {
                "value_id": "cp_game_price",
                "value_name": "投注",
                "fmt": "\"%.2f\" % a"
            },
            {
                "value_id": "cp_game_win",
                "value_name": "中奖",
                "fmt": "\"%.2f\" % a"
            },
            {
                "value_id": "cp_game_profit",
                "value_name": "利润",
                "value_expr": "cp_game_price - cp_game_win",
                "fmt": "\"%.2f\" % v"
            },
            {
                "value_id": "cp_game_profit_rate",
                "value_name": "利润率",
                "value_expr": "(cp_game_price - cp_game_win) / cp_game_price ",
                "fmt": "\"%.2f\" % (v * 100)"
            }
        ],
        "uv": {
            "field_id": "_user_id",
            "field_name": "投注人次"
        },
        "pv": {
            "field_name": "投注次数"
        }
    }
}


EVENT_CONFIG = {
    "event_id": "cp_game",
    "event_name": "电玩城分析",
    "values": {
        "_user_id": {
            "field_name": "用戶ID",
            "value_type": "long"
        },
        "seq_no": {
            "field_name": "期号",
            "value_type": "string",
            "required": False
        },
        "sub_type": {
            "field_name": "类型",
            "value_type": "string",
            "enum": {
                "target_enum_dct": CP_GAME_SUB_TYPE_DCT
            }
        },
        "third_type": {
            "field_name": "游戏",
            "value_type": "string",
            "enum": {
                "target_enum_dct": CP_GAME_THIRD_TYPE_DCT
            }
        },
        "out_trans_id": {
            "field_name": "訂單ID",
            "value_type": "long"
        },
        "bet_target": {
            "field_name": "投注对象",
            "value_type": "string",
        },
        "price": {
            "field_name": "投注",
            "value_type": "float",
        },
        "win": {
            "field_name": "中奖",
            "value_type": "float",
        },
        "profit": {
            "field_name": "盈利",
            "value_type": "float",
            "required": False
        }
    },
    "rule": EVENT_RULES
}




